package edu.infomatik.tundra.model;

import java.util.ArrayList;
import java.util.List;
import edu.infomatik.tundra.logic.WorkBean;
import edu.infomatik.tundra.logic.WorkKinds;
import org.apache.tapestry5.OptionGroupModel;
import org.apache.tapestry5.OptionModel;
import org.apache.tapestry5.util.AbstractSelectModel;

public class ProjectIdSelectModel extends AbstractSelectModel {
	
	private List<WorkBean> projects;
	
	public ProjectIdSelectModel(List<WorkBean> projects){
		this.projects = projects;
	}

	@Override
	public List<OptionGroupModel> getOptionGroups() {
		return null;
	}

	@Override
	public List<OptionModel> getOptions() {
		
		if (null != projects){
			List<OptionModel> list = new ArrayList<OptionModel>();
			
			for(WorkBean wb:projects)
				if (wb.getKind()==WorkKinds.PROJECT_VALUE)
					list.add(new ProjectIdOptionModel(wb));
			
			return list;
		}
		return null;
	}

}
